from DrissionPage import ChromiumPage
import subprocess

username = 'guangliang.han'
password = 'HGLnihao,6119'

url = ("http://10.15.254.68")

def jinko_auth(username, password):
    """
    进行认证
    :param username:用户名
    :param password:密码
    :return:
    """
    try:
        print("正在进行认证，请稍后...")

        page = ChromiumPage()
        # 访问网页
        page.get(url)

        page.ele('#password_name').input(username)
        page.ele('#password_pwd').input(password)

        page.ele('#password_submitBtn').click()

        page.wait.load_start()

        page.quit()

        print('登录成功')
    except Exception as e:
        print("认证发生错误：", e)


def killLockService():
    """
    关闭名为"locketdlpSvc"的进程
    :return:
    """
    try:
        names = ['locketdlpSvc.exe', 'locketdlpUI.exe', 'locketdlpUpdate.exe', 'locketdlp.exe']

        for name in names:
            subprocess.run(['taskkill', '/F', '/IM', name], capture_output=True)

    except Exception as e:
        print("锁屏服务杀死失败：", e)


if __name__ == '__main__':
    jinko_auth(username, password)
    killLockService()
